const {
  default: Toast
} = require("../../../../../miniprogram_npm/@vant/weapp/toast/toast");

const app = getApp()
Component({
  options: {
    addGlobalClass: true
  },
  /**
   * 组件的属性列表
   */
  properties: {
    item: {
      type: Object,
      value: {}
    },
    currentStoreId: {
      type: Number
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    baseURL: app.globalData.config.baseURL,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    //查看地理位置
    openLocation(e) {
      let data = this.data.item;
      wx.openLocation({
        name: data.shopName,
        address: data.sellerAddress,
        latitude: parseFloat(data.latitude),
        longitude: parseFloat(data.longitude)
      })
    },
    //调起电话
    toPhone(e) {
      let {
        phone
      } = e.currentTarget.dataset;
      if (phone) {
        wx.makePhoneCall({
          phoneNumber: phone
        })
      } else {
        Toast('没有联系电话')
      }
    },
    // 设置选中id
    setCheckedStoreId(e) {
      let {
        id
      } = e.currentTarget.dataset;
      this.triggerEvent('setCheckedStoreId', id)
    }
  },
  lifetimes: {
    attached: function () {

    }
  },
})